package com.github.panchitoboy.shiro.wechat.filter;

import org.apache.shiro.authc.AuthenticationToken;

public class WechatJWTAuthenticationToken implements AuthenticationToken {

	private static final long serialVersionUID = 1L;
	private Object phoneNumber;
	private String captcha;
	private String code;
    private String token;
    private boolean isLogin; //登录操作
    private String username;
    private String password;
    
    
    public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public WechatJWTAuthenticationToken(Object phoneNumber, String captcha, String code) {
        this.phoneNumber = phoneNumber;
        this.captcha = captcha;
        this.code = code;
        this.isLogin = true;
    }
	public WechatJWTAuthenticationToken(Object phoneNumber, String captcha, String code,String username,String password) {
        this.phoneNumber = phoneNumber;
        this.captcha = captcha;
        this.code = code;
        this.username=username;
        this.password=password;
        this.isLogin = true;
    }
    public WechatJWTAuthenticationToken(Object phoneNumber, String token) {
        this.phoneNumber = phoneNumber;
        this.token = token;
        this.isLogin = false;
    }

    @Override
    public Object getPrincipal() {
        return getPhoneNumber();
    }

    @Override
    public Object getCredentials() {
    	return this.isLogin ? getCaptcha() :getToken();
    }

    public Object getPhoneNumber() {
        return phoneNumber;
    }
    
	public void setPhoneNumber(Object phoneNumber) {
		this.phoneNumber = phoneNumber;
	}
	
	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getCaptcha() {
		return captcha;
	}

	public void setCaptcha(String captcha) {
		this.captcha = captcha;
	}
	
	public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }

	public boolean isLogin() {
		return isLogin;
	}

	public void setLogin(boolean isLogin) {
		this.isLogin = isLogin;
	}
}
